import type { DepartmentalInfo, DepartmentalSaveOrUpdateParams } from '@/types'

const controller = getAjaxBaseUrl('/sysDepartmental')

/** 新增或更新部门信息 */
export function saveOrUpdate(params: Partial<DepartmentalSaveOrUpdateParams>) {
  return post(`${controller}/saveOrUpdateDepartmental`, params)
}

/** 查询部门递归树 */
export function queryTreeList(id?: number) {
  return get<DepartmentalInfo[]>(`${controller}/queryDepartmentalTree`, { id })
}

/** 删除部门 */
export function deleteById(id: number) {
  return get(`${controller}/deleteDepartmental`, { id })
}

/** 通过部门ID查询用户列表 */
export function queryUserListById(id: number) {
  return get(`${controller}/queryUserListByDepartmentalId`, { id })
}
